/*
 * This file is part of Cadmium.
 * Copyright (C) 2007-2010 Xavier Clerc.
 *
 * Cadmium is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Cadmium is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package fr.x9c.cadmium.primitives.cadmiumjdbc;

import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import fr.x9c.cadmium.kernel.Block;
import fr.x9c.cadmium.kernel.CodeRunner;
import fr.x9c.cadmium.kernel.Custom;
import fr.x9c.cadmium.kernel.Fail;
import fr.x9c.cadmium.kernel.Primitive;
import fr.x9c.cadmium.kernel.PrimitiveProvider;
import fr.x9c.cadmium.kernel.Value;
import fr.x9c.cadmium.primitives.cadmium.Cadmium;

/**
 * This class provides the primitives related to the <tt>java.sql.DatabaseMetaData</tt> class.
 *
 * @author <a href="mailto:cadmium@x9c.fr">Xavier Clerc</a>
 * @version 1.1
 * @since 1.1
 */
@PrimitiveProvider
public final class DatabaseMetaDatas {

    /**
     * No instance of this class.
     */
    private DatabaseMetaDatas() {
    } // end empty constructor

    /**
     * Tests whether all procedures can be called.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if all procedures can be called,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_all_procedures_are_callable(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.allProceduresAreCallable() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_all_procedures_are_callable(CodeRunner, Value)'

    /**
     * Tests whether all tables can be selected.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if all tables can be selected,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_all_tables_are_selectable(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.allTablesAreSelectable() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_all_tables_are_selectable(CodeRunner, Value)'

    /**
     * Tests whether all result sets are closed upon failure.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if result sets are closed upon failure,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_auto_commit_failure_closes_all_result_sets(final CodeRunner ctxt,
                                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.autoCommitFailureClosesAllResultSets() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_auto_commit_failure_closes_all_result_sets(CodeRunner, Value)'

    /**
     * Tests whether data definition causes commit.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if data definition causes commit,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_data_definition_causes_transaction_commit(final CodeRunner ctxt,
                                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.dataDefinitionCausesTransactionCommit() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_data_definition_causes_transaction_commit(CodeRunner, Value)'

    /**
     * Tests whether data definitions are ignored in transactions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if data definitions are ignored in transactions,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_data_definition_ignored_in_transactions(final CodeRunner ctxt,
                                                                                             final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.dataDefinitionIgnoredInTransactions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_data_definition_ignored_in_transactions(CodeRunner, Value)'

    /**
     * Tests whether deletes are detected.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if deletes are detected,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_deletes_are_detected(final CodeRunner ctxt,
                                                                          final Value databasemetadata,
                                                                          final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.deletesAreDetected(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_deletes_are_detected(CodeRunner, Value, Value)'

    /**
     * Tests whether maximum row size include blobs.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if maximum row size include blobs,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_does_max_row_size_include_blobs(final CodeRunner ctxt,
                                                                                     final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.doesMaxRowSizeIncludeBlobs() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_does_max_row_size_include_blobs(CodeRunner, Value)'

    /**
     * Returns a result set describing a UDT.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schemaPattern schema pattern
     * @param typeNamePattern type name pattern
     * @param attributeNamePattern attribute name pattern
     * @return a result set describing a UDT
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_attributes(final CodeRunner ctxt,
                                                                    final Value databasemetadata,
                                                                    final Value catalog,
                                                                    final Value schemaPattern,
                                                                    final Value typeNamePattern,
                                                                    final Value attributeNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getAttributes(catalog.asBlock().asString(),
                                  schemaPattern.asBlock().asString(),
                                  typeNamePattern.asBlock().asString(),
                                  attributeNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_attributes(CodeRunner, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing the optimal set of column identifying a row.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @param scope scope
     * @param nullable whether nullable columns should be included
     * @return a result set containing the optimal set of column identifying a row
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_best_row_identifier(final CodeRunner ctxt,
                                                                             final Value databasemetadata,
                                                                             final Value catalog,
                                                                             final Value schema,
                                                                             final Value table,
                                                                             final Value scope,
                                                                             final Value nullable)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getBestRowIdentifier(catalog.asBlock().asString(),
                                         schema.asBlock().asString(),
                                         table.asBlock().asString(),
                                         Misc.decodeResultScope(scope),
                                         nullable == Value.TRUE);
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_best_row_identifier(CodeRunner, Value, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing the optimal set of column identifying a row.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @param scope scope
     * @param nullable whether nullable columns should be included
     * @return a result set containing the optimal set of column identifying a row
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_best_row_identifier_native(final CodeRunner ctxt,
                                                                                    final Value databasemetadata,
                                                                                    final Value catalog,
                                                                                    final Value schema,
                                                                                    final Value table,
                                                                                    final Value scope,
                                                                                    final Value nullable)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getBestRowIdentifier(catalog.asBlock().asString(),
                                         schema.asBlock().asString(),
                                         table.asBlock().asString(),
                                         Misc.decodeResultScope(scope),
                                         nullable == Value.TRUE);
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_best_row_identifier_native(CodeRunner, Value, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing the catalog names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return a result set containing the catalog names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_catalogs(final CodeRunner ctxt,
                                                                  final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res = dmd.getCatalogs();
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_catalogs(CodeRunner, Value)'

    /**
     * Returns the separator using between catalog and table name.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the separator using between catalog and table name
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_catalog_separator(final CodeRunner ctxt,
                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getCatalogSeparator());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_catalog_separator(CodeRunner, Value)'

    /**
     * Returns the term used for "catalog".
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the term used for "catalog"
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_catalog_term(final CodeRunner ctxt,
                                                                      final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getCatalogTerm());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_catalog_term(CodeRunner, Value)'

    /**
     * Returns a result set containing the client info properties for the driver.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return a result set containing the client info properties for the driver
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_client_info_properties(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res = dmd.getClientInfoProperties();
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_client_info_properties(CodeRunner, Value)'

    /**
     * Returns a result set containing column privileges.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @param columnNamePattern column name pattern
     * @return a result set containing column privileges
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_column_privileges(final CodeRunner ctxt,
                                                                           final Value databasemetadata,
                                                                           final Value catalog,
                                                                           final Value schema,
                                                                           final Value table,
                                                                           final Value columnNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getColumnPrivileges(catalog.asBlock().asString(),
                                        schema.asBlock().asString(),
                                        table.asBlock().asString(),
                                        columnNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_column_privileges(CodeRunner, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing column informations.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schemaPattern schema pattern
     * @param tableNamePattern table name pattern
     * @param columnNamePattern column name pattern
     * @return a result set containing column informations
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_columns(final CodeRunner ctxt,
                                                                 final Value databasemetadata,
                                                                 final Value catalog,
                                                                 final Value schemaPattern,
                                                                 final Value tableNamePattern,
                                                                 final Value columnNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getColumns(catalog.asBlock().asString(),
                               schemaPattern.asBlock().asString(),
                               tableNamePattern.asBlock().asString(),
                               columnNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_columns(CodeRunner, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing the cross references of the database.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param parentCatalog parent catalog
     * @param parentSchema parent schema
     * @param parentTable parent table
     * @param foreignCatalog foreign catalog
     * @param foreignSchema foreign schema
     * @param foreignTable foreign table
     * @return a result set containing the cross references of the database
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_cross_reference(final CodeRunner ctxt,
                                                                         final Value databasemetadata,
                                                                         final Value parentCatalog,
                                                                         final Value parentSchema,
                                                                         final Value parentTable,
                                                                         final Value foreignCatalog,
                                                                         final Value foreignSchema,
                                                                         final Value foreignTable)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getCrossReference(parentCatalog.asBlock().asString(),
                                      parentSchema.asBlock().asString(),
                                      parentTable.asBlock().asString(),
                                      foreignCatalog.asBlock().asString(),
                                      foreignSchema.asBlock().asString(),
                                      foreignTable.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_cross_reference(CodeRunner, Value, Value, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing the cross references of the database.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param parentCatalog parent catalog
     * @param parentSchema parent schema
     * @param parentTable parent table
     * @param foreignCatalog foreign catalog
     * @param foreignSchema foreign schema
     * @param foreignTable foreign table
     * @return a result set containing the cross references of the database
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_cross_reference_native(final CodeRunner ctxt,
                                                                                final Value databasemetadata,
                                                                                final Value parentCatalog,
                                                                                final Value parentSchema,
                                                                                final Value parentTable,
                                                                                final Value foreignCatalog,
                                                                                final Value foreignSchema,
                                                                                final Value foreignTable)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getCrossReference(parentCatalog.asBlock().asString(),
                                      parentSchema.asBlock().asString(),
                                      parentTable.asBlock().asString(),
                                      foreignCatalog.asBlock().asString(),
                                      foreignSchema.asBlock().asString(),
                                      foreignTable.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_cross_reference_native(CodeRunner, Value, Value, Value, Value, Value, Value, Value)'

    /**
     * Returns the major component of the database version.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the major component of the database version
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_database_major_version(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getDatabaseMajorVersion());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_database_major_version(CodeRunner, Value)'

    /**
     * Returns the minor component of the database version.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the minor component of the database version
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_database_minor_version(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getDatabaseMinorVersion());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_database_minor_version(CodeRunner, Value)'

    /**
     * Returns the database product name.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the database product name
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_database_product_name(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getDatabaseProductName());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_database_product_name(CodeRunner, Value)'

    /**
     * Returns the database product version.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the database product version
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_database_product_version(final CodeRunner ctxt,
                                                                                  final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getDatabaseProductVersion());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_database_product_version(CodeRunner, Value)'

    /**
     * Returns the default transaction isolation level.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the default transaction isolation level
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_default_transaction_isolation(final CodeRunner ctxt,
                                                                                       final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return Misc.encodeTransactionIsolation(dmd.getDefaultTransactionIsolation());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_default_transaction_isolation(CodeRunner, Value)'

    /**
     * Returns the major component of the driver version.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the major component of the driver version
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_driver_major_version(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getDriverMajorVersion());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_driver_major_version(CodeRunner, Value)'

    /**
     * Returns the minor component of the driver version.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the minor component of the driver version
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_driver_minor_version(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getDriverMinorVersion());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_driver_minor_version(CodeRunner, Value)'

    /**
     * Returns the driver name.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the driver name
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_driver_name(final CodeRunner ctxt,
                                                                     final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getDriverName());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_driver_name(CodeRunner, Value)'

    /**
     * Returns the driver version.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the driver version
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_driver_version(final CodeRunner ctxt,
                                                                        final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getDriverVersion());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_driver_version(CodeRunner, Value)'

    /**
     * Returns a result set containing exported keys.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @return a result set containing exported keys
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_exported_keys(final CodeRunner ctxt,
                                                                       final Value databasemetadata,
                                                                       final Value catalog,
                                                                       final Value schema,
                                                                       final Value table)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res = dmd.getExportedKeys(catalog.asBlock().asString(),
                                                      schema.asBlock().asString(),
                                                      table.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_exported_keys(CodeRunner, Value, Value, Value, Value)'

    /**
     * Returns the extra characters that can be used in identifiers.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the extra characters that can be used in identifiers
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_extra_name_characters(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getExtraNameCharacters());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_extra_name_characters(CodeRunner, Value)'

    /**
     * Returns a result set containing functions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog
     * @param schemaPattern schema pattern
     * @param functionNamePattern function name pattern
     * @param columnNamePattern column name pattern
     * @return a result set containing functions
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_function_columns(final CodeRunner ctxt,
                                                                          final Value databasemetadata,
                                                                          final Value catalog,
                                                                          final Value schemaPattern,
                                                                          final Value functionNamePattern,
                                                                          final Value columnNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getFunctionColumns(catalog.asBlock().asString(),
                                       schemaPattern.asBlock().asString(),
                                       functionNamePattern.asBlock().asString(),
                                       columnNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_function_columns(CodeRunner, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing functions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog
     * @param schemaPattern schema pattern
     * @param functionNamePattern function name pattern
     * @return a result set containing functions
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_functions(final CodeRunner ctxt,
                                                                   final Value databasemetadata,
                                                                   final Value catalog,
                                                                   final Value schemaPattern,
                                                                   final Value functionNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getFunctions(catalog.asBlock().asString(),
                                 schemaPattern.asBlock().asString(),
                                 functionNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_functions(CodeRunner, Value, Value, Value, Value)'

    /**
     * Returns the string used in order to quote identifiers.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the string used in order to quote identifiers
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_identifier_quote_string(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getIdentifierQuoteString());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_identifier_quote_string(CodeRunner, Value)'

    /**
     * Returns a result set describing imported keys.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @return a result set describing imported keys
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_imported_keys(final CodeRunner ctxt,
                                                                       final Value databasemetadata,
                                                                       final Value catalog,
                                                                       final Value schema,
                                                                       final Value table)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getImportedKeys(catalog.asBlock().asString(),
                                    schema.asBlock().asString(),
                                    table.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_imported_keys(CodeRunner, Value, Value, Value, Value)'

    /**
     * Returns a result set describing the indexes
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @param unique whether only indexes for unique values should be included
     * @param approximate whether approximate values should be included
     * @return a result set describing the indexes
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_index_info(final CodeRunner ctxt,
                                                                    final Value databasemetadata,
                                                                    final Value catalog,
                                                                    final Value schema,
                                                                    final Value table,
                                                                    final Value unique,
                                                                    final Value approximate)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getIndexInfo(catalog.asBlock().asString(),
                                 schema.asBlock().asString(),
                                 table.asBlock().asString(),
                                 unique == Value.TRUE,
                                 approximate == Value.TRUE);
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_index_info(CodeRunner, Value, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set describing the indexes
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @param unique whether only indexes for unique values should be included
     * @param approximate whether approximate values should be included
     * @return a result set describing the indexes
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_index_info_native(final CodeRunner ctxt,
                                                                           final Value databasemetadata,
                                                                           final Value catalog,
                                                                           final Value schema,
                                                                           final Value table,
                                                                           final Value unique,
                                                                           final Value approximate)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getIndexInfo(catalog.asBlock().asString(),
                                 schema.asBlock().asString(),
                                 table.asBlock().asString(),
                                 unique == Value.TRUE,
                                 approximate == Value.TRUE);
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_index_info_native(CodeRunner, Value, Value, Value, Value, Value, Value)'

    /**
     * Returns the major component of the JDBC version.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the major component of the JDBC version
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_jdbc_major_version(final CodeRunner ctxt,
                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getJDBCMajorVersion());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_jdbc_major_version(CodeRunner, Value)'

    /**
     * Returns the minor component of the JDBC version.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the minor component of the JDBC version
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_jdbc_minor_version(final CodeRunner ctxt,
                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getJDBCMinorVersion());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_jdbc_minor_version(CodeRunner, Value)'

    /**
     * Returns the maximum length of binary literals.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of binary literals
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_binary_literal_length(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxBinaryLiteralLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_binary_literal_length(CodeRunner, Value)'

    /**
     * Returns the maximum length of catalog names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of catalog names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_catalog_name_length(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxCatalogNameLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_catalog_name_length(CodeRunner, Value)'

    /**
     * Returns the maximum length of character literals.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of character literals
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_char_literal_length(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxCharLiteralLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_char_literal_length(CodeRunner, Value)'

    /**
     * Returns the maximum length of column names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of column names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_column_name_length(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxColumnNameLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_column_name_length(CodeRunner, Value)'

    /**
     * Returns the maximum number of columns in <i>group by</i>.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum number of columns in <i>group by</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_columns_in_group_by(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxColumnsInGroupBy());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_columns_in_group_by(CodeRunner, Value)'

    /**
     * Returns the maximum number of columns in index.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum number of columns in index
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_columns_in_index(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxColumnsInIndex());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_columns_in_index(CodeRunner, Value)'

    /**
     * Returns the maximum number of columns in <i>order by</i>.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum number of columns in <i>order by</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_columns_in_order_by(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxColumnsInOrderBy());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_columns_in_order_by(CodeRunner, Value)'

    /**
     * Returns the maximum number of columns in <i>select</i>.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum number of columns in <i>select</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_columns_in_select(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxColumnsInSelect());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_columns_in_select(CodeRunner, Value)'

    /**
     * Returns the maximum number of columns in tables.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum number of columns in tables
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_columns_in_table(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxColumnsInTable());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_columns_in_table(CodeRunner, Value)'

    /**
     * Returns the maximum number of connections.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum number of connections
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_connections(final CodeRunner ctxt,
                                                                         final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxConnections());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_connections(CodeRunner, Value)'

    /**
     * Returns the maximum length of cursor names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of cursor names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_cursor_name_length(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxCursorNameLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_cursor_name_length(CodeRunner, Value)'

    /**
     * Returns the maximum length for indexes.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length for indexes
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_index_length(final CodeRunner ctxt,
                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxIndexLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_index_length(CodeRunner, Value)'

    /**
     * Returns the maximum length of procedure names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of procedure names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_procedure_name_length(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxProcedureNameLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_procedure_name_length(CodeRunner, Value)'

    /**
     * Returns the maximum row size.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum row size
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_row_size(final CodeRunner ctxt,
                                                                      final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxRowSize());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_row_size(CodeRunner, Value)'

    /**
     * Returns the maximum length of schema names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of schema names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_schema_name_length(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxSchemaNameLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_schema_name_length(CodeRunner, Value)'

    /**
     * Returns the maximum length of statements.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of statements
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_statement_length(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxStatementLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_statement_length(CodeRunner, Value)'

    /**
     * Returns the maximum number of statements.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum number of statements
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_statements(final CodeRunner ctxt,
                                                                        final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxStatements());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_statements(CodeRunner, Value)'

    /**
     * Returns the maximum length of table names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of table names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_table_name_length(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxTableNameLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_table_name_length(CodeRunner, Value)'

    /**
     * Returns the maximum number of tables in <i>select</i>.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum number of tables in <i>select</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_tables_in_select(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxTablesInSelect());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_tables_in_select(CodeRunner, Value)'

    /**
     * Returns the maximum length of user names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the maximum length of user names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_max_user_name_length(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(dmd.getMaxUserNameLength());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_max_user_name_length(CodeRunner, Value)'

    /**
     * Returns the comma-separated list of numeric functions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the comma-separated list of numeric functions
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_numeric_functions(final CodeRunner ctxt,
                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getNumericFunctions());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_numeric_functions(CodeRunner, Value)'

    /**
     * Returns a result set containing primary keys.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @return a result set containing primary keys
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_primary_keys(final CodeRunner ctxt,
                                                                      final Value databasemetadata,
                                                                      final Value catalog,
                                                                      final Value schema,
                                                                      final Value table)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getPrimaryKeys(catalog.asBlock().asString(),
                                   schema.asBlock().asString(),
                                   table.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_primary_keys(CodeRunner, Value, Value, Value, Value)'

    /**
     * Returns a result set containing procedures.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog
     * @param schemaPattern schema pattern
     * @param procedureNamePattern procedure name pattern
     * @param columnNamePattern column name pattern
     * @return a result set containing procedures
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_procedure_columns(final CodeRunner ctxt,
                                                                           final Value databasemetadata,
                                                                           final Value catalog,
                                                                           final Value schemaPattern,
                                                                           final Value procedureNamePattern,
                                                                           final Value columnNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getProcedureColumns(catalog.asBlock().asString(),
                                        schemaPattern.asBlock().asString(),
                                        procedureNamePattern.asBlock().asString(),
                                        columnNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_procedure_columns(CodeRunner, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing procedures.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog
     * @param schemaPattern schema pattern
     * @param procedureNamePattern procedure name pattern
     * @return a result set containing procedures
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_procedures(final CodeRunner ctxt,
                                                                    final Value databasemetadata,
                                                                    final Value catalog,
                                                                    final Value schemaPattern,
                                                                    final Value procedureNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getProcedures(catalog.asBlock().asString(),
                                  schemaPattern.asBlock().asString(),
                                  procedureNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_procedures(CodeRunner, Value, Value, Value, Value)'

    /**
     * Returns the term used for "procedure".
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the term used for "procedure"
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_procedure_term(final CodeRunner ctxt,
                                                                        final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getProcedureTerm());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_procedure_term(CodeRunner, Value)'

    /**
     * Returns the default holdability.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the default holdability
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_result_set_holdability(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return Misc.encodeResultSetHoldability(dmd.getResultSetHoldability());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_result_set_holdability(CodeRunner, Value)'

    /**
     * Returns the lifetime of rowid elements.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the lifetime of rowid elements
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_row_id_lifetime(final CodeRunner ctxt,
                                                                         final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return Misc.encodeRowIdLifetime(dmd.getRowIdLifetime());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_row_id_lifetime(CodeRunner, Value)'

    /**
     * Returns a result set containing the schema names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return a result set containing the schema names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_schemas(final CodeRunner ctxt,
                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res = dmd.getSchemas();
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_schemas(CodeRunner, Value)'

    /**
     * Returns a result set containing the schema names.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schemaPattern schema pattern
     * @return a result set containing the schema names
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_schemas_params(final CodeRunner ctxt,
                                                                        final Value databasemetadata,
                                                                        final Value catalog,
                                                                        final Value schemaPattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res = dmd.getSchemas(catalog.asBlock().asString(),
                                                 schemaPattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_schemas_params(CodeRunner, Value, Value, Value)'

    /**
     * Returns the term used for "schema".
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the term used for "schema"
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_schema_term(final CodeRunner ctxt,
                                                                     final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getSchemaTerm());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_schema_term(CodeRunner, Value)'

    /**
     * Returns the string used to escape wilcard characters.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the string used to escape wilcard characters
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_search_string_escape(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getSearchStringEscape());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_search_string_escape(CodeRunner, Value)'

    /**
     * Returns the comma-separated list of SQL keywords.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the comma-separated list of SQL keywords
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_sql_keywords(final CodeRunner ctxt,
                                                                      final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getSQLKeywords());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_sql_keywords(CodeRunner, Value)'

    /**
     * Returns the SQL state type.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the SQL state type
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_sql_state_type(final CodeRunner ctxt,
                                                                        final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return Misc.encodeSQLStateType(dmd.getSQLStateType());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_sql_state_type(CodeRunner, Value)'

    /**
     * Returns the comma-separated list of string functions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the comma-separated list of string functions
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_string_functions(final CodeRunner ctxt,
                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getStringFunctions());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_string_functions(CodeRunner, Value)'

    /**
     * Returns a result set describing the table hierarchy.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schemaPattern schema pattern
     * @param tableNamePattern table name pattern
     * @return a result set describing the table hierarchy
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_super_tables(final CodeRunner ctxt,
                                                                      final Value databasemetadata,
                                                                      final Value catalog,
                                                                      final Value schemaPattern,
                                                                      final Value tableNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getSuperTables(catalog.asBlock().asString(),
                                   schemaPattern.asBlock().asString(),
                                   tableNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_super_tables(CodeRunner, Value, Value, Value, Value)'

    /**
     * Returns a result set describing the type hierarchy.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schemaPattern schema pattern
     * @param typeNamePattern type name pattern
     * @return a result set describing the type hierarchy
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_super_types(final CodeRunner ctxt,
                                                                     final Value databasemetadata,
                                                                     final Value catalog,
                                                                     final Value schemaPattern,
                                                                     final Value typeNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getSuperTypes(catalog.asBlock().asString(),
                                  schemaPattern.asBlock().asString(),
                                  typeNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_super_types(CodeRunner, Value, Value, Value, Value)'

    /**
     * Returns the comma-separated list of system functions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the comma-separated list of system functions
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_system_functions(final CodeRunner ctxt,
                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getSystemFunctions());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_system_functions(CodeRunner, Value)'

    /**
     * Returns a result set describing table privileges.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schemaPattern schema pattern
     * @param tableNamePattern table name pattern
     * @return a result set describing table privileges
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_table_privileges(final CodeRunner ctxt,
                                                                          final Value databasemetadata,
                                                                          final Value catalog,
                                                                          final Value schemaPattern,
                                                                          final Value tableNamePattern)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getTablePrivileges(catalog.asBlock().asString(),
                                       schemaPattern.asBlock().asString(),
                                       tableNamePattern.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_table_privileges(CodeRunner, Value, Value, Value, Value)'

    /**
     * Returns a result set describing the available tables.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schemaPattern schema pattern
     * @param tableNamePattern table name pattern
     * @param types type list
     * @return a result set describing the available tables
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_tables(final CodeRunner ctxt,
                                                                final Value databasemetadata,
                                                                final Value catalog,
                                                                final Value schemaPattern,
                                                                final Value tableNamePattern,
                                                                final Value types)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final List<String> t = new ArrayList<String>();
            Value list = types;
            while (list != Value.EMPTY_LIST) {
                final Block b = list.asBlock();
                t.add(b.get(0).asBlock().asString());
                list = b.get(1);
            } // end while
            final ResultSet res =
                dmd.getTables(catalog.asBlock().asString(),
                              schemaPattern.asBlock().asString(),
                              tableNamePattern.asBlock().asString(),
                              t.toArray(new String[t.size()]));
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_tables(CodeRunner, Value, Value, Value, Value, Value)'

    /**
     * Returns a result set containing the table types.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return a result set containing the table types
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_table_types(final CodeRunner ctxt,
                                                                     final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res = dmd.getTableTypes();
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_table_types(CodeRunner, Value)'

    /**
     * Returns the comma-separated list of date/time functions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the comma-separated list of date/time functions
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_time_date_functions(final CodeRunner ctxt,
                                                                             final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getTimeDateFunctions());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_time_date_functions(CodeRunner, Value)'

    /**
     * Returns a result set containing the type information.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return a result set containing the type information
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_type_info(final CodeRunner ctxt,
                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res = dmd.getTypeInfo();
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_type_info(CodeRunner, Value)'

    /**
     * Returns a result set describing the UDTs.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schemaPattern schema pattern
     * @param typeNamePattern type name pattern
     * @param types type list
     * @return a result set describing the UDTs
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_udts(final CodeRunner ctxt,
                                                              final Value databasemetadata,
                                                              final Value catalog,
                                                              final Value schemaPattern,
                                                              final Value typeNamePattern,
                                                              final Value types)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final List<Integer> t = new ArrayList<Integer>();
            Value list = types;
            while (list != Value.EMPTY_LIST) {
                final Block b = list.asBlock();
                t.add(Misc.decodeJDBCType(b.get(0)));
                list = b.get(1);
            } // end while
            final int len = t.size();
            final int[] tt = new int[len];
            int i = 0;
            for (int v : t) {
                tt[i++] = v;
            } // end for
            final ResultSet res =
                dmd.getUDTs(catalog.asBlock().asString(),
                            schemaPattern.asBlock().asString(),
                            typeNamePattern.asBlock().asString(),
                            tt);
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_udts(CodeRunner, Value, Value, Value, Value, Value)'

    /**
     * Returns the URL of the database.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the URL of the database
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_url(final CodeRunner ctxt,
                                                             final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getURL());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_url(CodeRunner, Value)'

    /**
     * Returns the user name.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return the user name
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_user_name(final CodeRunner ctxt,
                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final Block res = Block.createString(dmd.getUserName());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_user_name(CodeRunner, Value)'

    /**
     * Returns a result set describing version columns.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param catalog catalog name
     * @param schema schema name
     * @param table table name
     * @return a result set describing version columns
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_get_version_columns(final CodeRunner ctxt,
                                                                         final Value databasemetadata,
                                                                         final Value catalog,
                                                                         final Value schema,
                                                                         final Value table)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            final ResultSet res =
                dmd.getVersionColumns(catalog.asBlock().asString(),
                                      schema.asBlock().asString(),
                                      table.asBlock().asString());
            return Cadmium.createObject(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_get_version_columns(CodeRunner, Value, Value, Value, Value)'

    /**
     * Tests whether inserts are detected.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param type type to test
     * @return <tt>true</tt> if inserts are detected,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_inserts_are_detected(final CodeRunner ctxt,
                                                                          final Value databasemetadata,
                                                                          final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.insertsAreDetected(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_inserts_are_detected(CodeRunner, Value, Value)'

    /**
     * Tests whether catalog appears at start of qualified table name.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if catalog appears at start of qualified table name,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_is_catalog_at_start(final CodeRunner ctxt,
                                                                         final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.isCatalogAtStart() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_is_catalog_at_start(CodeRunner, Value)'

    /**
     * Tests whether the database is readonly.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if the database is readonly,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_is_read_only(final CodeRunner ctxt,
                                                                  final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.isReadOnly() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_is_read_only(CodeRunner, Value)'

    /**
     * Tests whether <i>x</i>LOB updates are made on a copy or directly.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>x</i>LOB updates are made on a copy,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_locators_update_copy(final CodeRunner ctxt,
                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.locatorsUpdateCopy() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_locators_update_copy(CodeRunner, Value)'

    /**
     * Tests whether <i>null + null</i> equals <i>null</i>.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>null + null</i> equals <i>null</i>,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_null_plus_non_null_is_null(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.nullPlusNonNullIsNull() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_null_plus_non_null_is_null(CodeRunner, Value)'

    /**
     * Tests whether <i>null</i> values are sorted at end.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>null</i> values are sorted at end,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_nulls_are_sorted_at_end(final CodeRunner ctxt,
                                                                             final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.nullsAreSortedAtEnd() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_nulls_are_sorted_at_end(CodeRunner, Value)'

    /**
     * Tests whether <i>null</i> values are sorted at start.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>null</i> values are sorted at start,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_nulls_are_sorted_at_start(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.nullsAreSortedAtStart() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_nulls_are_sorted_at_start(CodeRunner, Value)'

    /**
     * Tests whether <i>null</i> values are sorted high.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>null</i> values are sorted high,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_nulls_are_sorted_high(final CodeRunner ctxt,
                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.nullsAreSortedHigh() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_nulls_are_sorted_high(CodeRunner, Value)'

    /**
     * Tests whether <i>null</i> values are sorted low.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>null</i> values are sorted low,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_nulls_are_sorted_low(final CodeRunner ctxt,
                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.nullsAreSortedLow() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_nulls_are_sorted_low(CodeRunner, Value)'

    /**
     * Tests whether deletes made by others are visible.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if deletes made by others are visible,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_others_deletes_are_visible(final CodeRunner ctxt,
                                                                                final Value databasemetadata,
                                                                                final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.othersDeletesAreVisible(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_others_deletes_are_visible(CodeRunner, Value, Value)'

    /**
     * Tests whether inserts made by others are visible.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if inserts made by others are visible,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_others_inserts_are_visible(final CodeRunner ctxt,
                                                                                final Value databasemetadata,
                                                                                final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.othersInsertsAreVisible(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_others_inserts_are_visible(CodeRunner, Value, Value)'

    /**
     * Tests whether updates made by others are visible.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if updates made by others are visible,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_others_updates_are_visible(final CodeRunner ctxt,
                                                                                final Value databasemetadata,
                                                                                final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.othersUpdatesAreVisible(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_others_updates_are_visible(CodeRunner, Value, Value)'

    /**
     * Tests whether deletes made by the same result set are visible.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if deletes made by the same result set are visible,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_own_deletes_are_visible(final CodeRunner ctxt,
                                                                             final Value databasemetadata,
                                                                             final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.ownDeletesAreVisible(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_own_deletes_are_visible(CodeRunner, Value, Value)'

    /**
     * Tests whether inserts made by the same result set are visible.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if inserts made by the same result set are visible,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_own_inserts_are_visible(final CodeRunner ctxt,
                                                                             final Value databasemetadata,
                                                                             final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.ownInsertsAreVisible(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_own_inserts_are_visible(CodeRunner, Value, Value)'

    /**
     * Tests whether updates made by the same result set are visible.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if updates made by the same result set are visible,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_own_updates_are_visible(final CodeRunner ctxt,
                                                                             final Value databasemetadata,
                                                                             final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.ownUpdatesAreVisible(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_own_updates_are_visible(CodeRunner, Value, Value)'

    /**
     * Tests whether identifiers are stored in lower case form.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if identifiers are stored in lower case form,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_stores_lower_case_identifiers(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.storesLowerCaseIdentifiers() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_stores_lower_case_identifiers(CodeRunner, Value)'

    /**
     * Tests whether quoted identifiers are stored in lower case form.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if quoted identifiers are stored in lower case form,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_stores_lower_case_quoted_identifiers(final CodeRunner ctxt,
                                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.storesLowerCaseQuotedIdentifiers() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_stores_lower_case_quoted_identifiers(CodeRunner, Value)'

    /**
     * Tests whether identifiers are stored in mixed case form.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if identifiers are stored in mixed case form,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_stores_mixed_case_identifiers(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.storesMixedCaseIdentifiers() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_stores_mixed_case_identifiers(CodeRunner, Value)'

    /**
     * Tests whether quoted identifiers are stored in mixed case form.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if quoted identifiers are stored in mixed case form,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_stores_mixed_case_quoted_identifiers(final CodeRunner ctxt,
                                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.storesMixedCaseQuotedIdentifiers() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_stores_mixed_case_quoted_identifiers(CodeRunner, Value)'

    /**
     * Tests whether identifiers are stored in upper case form.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if identifiers are stored in upper case form,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_stores_upper_case_identifiers(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.storesUpperCaseIdentifiers() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_stores_upper_case_identifiers(CodeRunner, Value)'

    /**
     * Tests whether quoted identifiers are stored in upper case form.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if quoted identifiers are stored in upper case form,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_stores_upper_case_quoted_identifiers(final CodeRunner ctxt,
                                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.storesUpperCaseQuotedIdentifiers() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_stores_upper_case_quoted_identifiers(CodeRunner, Value)'

    /**
     * Tests whether column addition is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if column addition is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_alter_table_with_add_column(final CodeRunner ctxt,
                                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsAlterTableWithAddColumn() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_alter_table_with_add_column(CodeRunner, Value)'

    /**
     * Tests whether column deletion is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if column deletion is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_alter_table_with_drop_column(final CodeRunner ctxt,
                                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsAlterTableWithDropColumn() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_alter_table_with_drop_column(CodeRunner, Value)'

    /**
     * Tests whether ANSI92 entry level is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if ANSI92 entry level is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_ansi92_entry_level_sql(final CodeRunner ctxt,
                                                                                     final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsANSI92EntryLevelSQL() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_ansi92_entry_level_sql(CodeRunner, Value)'

    /**
     * Tests whether ANSI92 is fully supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if ANSI92 is fully supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_ansi92_full_sql(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsANSI92FullSQL() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_ansi92_full_sql(CodeRunner, Value)'

    /**
     * Tests whether ANSI92 intermediate level is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if ANSI92 intermediate level is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_ansi92_intermediate_sql(final CodeRunner ctxt,
                                                                                      final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsANSI92IntermediateSQL() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_ansi92_intermediate_sql(CodeRunner, Value)'

    /**
     * Tests whether batch updates are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if batch updates are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_batch_updates(final CodeRunner ctxt,
                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsBatchUpdates() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_batch_updates(CodeRunner, Value)'

    /**
     * Tests whether catalogs can be used in data manipulation.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if catalogs can be used in data manipulation,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_catalogs_in_data_manipulation(final CodeRunner ctxt,
                                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsCatalogsInDataManipulation() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_catalogs_in_data_manipulation(CodeRunner, Value)'

    /**
     * Tests whether catalogs can be used in index definition.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if catalogs can be used in index definition,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_catalogs_in_index_definitions(final CodeRunner ctxt,
                                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsCatalogsInIndexDefinitions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_catalogs_in_index_definitions(CodeRunner, Value)'

    /**
     * Tests whether catalogs can be used in privilege definition.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if catalogs can be used in privilege definition,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_catalogs_in_privilege_definitions(final CodeRunner ctxt,
                                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsCatalogsInPrivilegeDefinitions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_catalogs_in_privilege_definitions(CodeRunner, Value)'

    /**
     * Tests whether catalogs can be used in procedure call.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if catalogs can be used in procedure call,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_catalogs_in_procedure_calls(final CodeRunner ctxt,
                                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsCatalogsInProcedureCalls() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_catalogs_in_procedure_calls(CodeRunner, Value)'

    /**
     * Tests whether catalogs can be used in table definition.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if catalogs can be used in table definition,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_catalogs_in_table_definitions(final CodeRunner ctxt,
                                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsCatalogsInTableDefinitions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_catalogs_in_table_definitions(CodeRunner, Value)'

    /**
     * Tests whether column aliasing is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if column aliasing is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_column_aliasing(final CodeRunner ctxt,
                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsColumnAliasing() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_column_aliasing(CodeRunner, Value)'

    /**
     * Tests whether <i>convert</i> is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>convert</i> is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_convert(final CodeRunner ctxt,
                                                                      final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsConvert() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_convert(CodeRunner, Value)'

    /**
     * Tests whether <i>convert</i> is supported for passed types.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param from source type
     * @param to destination type
     * @return <tt>true</tt> if <i>convert</i> is supported for passed types,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_convert_types(final CodeRunner ctxt,
                                                                            final Value databasemetadata,
                                                                            final Value from,
                                                                            final Value to)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsConvert(Misc.decodeJDBCType(from),
                                       Misc.decodeJDBCType(to))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_convert_types(CodeRunner, Value, Value, Value)'

    /**
     * Tests whether ODBC SQL is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if ODBC SQL is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_core_sql_grammar(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsCoreSQLGrammar() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_core_sql_grammar(CodeRunner, Value)'

    /**
     * Tests whether correlated subqueries are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if correlated subqueries are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_correlated_subqueries(final CodeRunner ctxt,
                                                                                    final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsCorrelatedSubqueries() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_correlated_subqueries(CodeRunner, Value)'

    /**
     * Tests whether data definition and manipulation is supported inside transactions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if data definition and manipulation is supported inside transactions,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_data_definition_and_data_manipulation_transactions(final CodeRunner ctxt,
                                                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsDataDefinitionAndDataManipulationTransactions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_data_definition_and_data_manipulation_transactions(CodeRunner, Value)'

    /**
     * Tests whether data manipulation is supported inside transactions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if data manipulation is supported inside transactions,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_data_manipulation_transactions_only(final CodeRunner ctxt,
                                                                                                  final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsDataManipulationTransactionsOnly() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_data_manipulation_transactions_only(CodeRunner, Value)'

    /**
     * Tests whether different table names can be used in correlation.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if different table names can be used in correlation,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_different_table_correlation_names(final CodeRunner ctxt,
                                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsDifferentTableCorrelationNames() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_different_table_correlation_names(CodeRunner, Value)'

    /**
     * Tests whether expressions are supported in <i>order by</i> clauses.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if expressions are supported in <i>order by</i> clauses,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_expressions_in_order_by(final CodeRunner ctxt,
                                                                                      final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsExpressionsInOrderBy() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_expressions_in_order_by(CodeRunner, Value)'

    /**
     * Tests whether extended ODBC SQL is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if extended ODBC SQL is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_extended_sql_grammar(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsExtendedSQLGrammar() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_extended_sql_grammar(CodeRunner, Value)'

    /**
     * Tests whether full outer joins are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if full outer joins are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_full_outer_joins(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsFullOuterJoins() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_full_outer_joins(CodeRunner, Value)'

    /**
     * Tests whether generated key retrieval is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if generated key retrieval is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_get_generated_keys(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsGetGeneratedKeys() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_get_generated_keys(CodeRunner, Value)'

    /**
     * Tests whether <i>group by</i> is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>group by</i> is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_group_by(final CodeRunner ctxt,
                                                                       final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsGroupBy() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_group_by(CodeRunner, Value)'

    /**
     * Tests whether <i>group by</i> beyond <i>select</i> is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>group by</i> beyond <i>select</i> is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_group_by_beyond_select(final CodeRunner ctxt,
                                                                                     final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsGroupByBeyondSelect() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_group_by_beyond_select(CodeRunner, Value)'

    /**
     * Tests whether <i>group by</i> over column outside <i>select</i> is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>group by</i> over column outside <i>select</i> is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_group_by_unrelated(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsGroupByUnrelated() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_group_by_unrelated(CodeRunner, Value)'

    /**
     * Tests whether the database supports the SQL integrity enhancement facility.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if the database supports the SQL integrity enhancement facility,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_integrity_enhancement_facility(final CodeRunner ctxt,
                                                                                             final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsIntegrityEnhancementFacility() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_integrity_enhancement_facility(CodeRunner, Value)'

    /**
     * Tests whether the <i>like</i> clause is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if the <i>like</i> clause is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_like_escape_clause(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsLikeEscapeClause() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_like_escape_clause(CodeRunner, Value)'

    /**
     * Tests whether limited outer joins are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if limited outer joins are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_limited_outer_joins(final CodeRunner ctxt,
                                                                                  final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsLimitedOuterJoins() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_limited_outer_joins(CodeRunner, Value)'

    /**
     * Tests whether minimum ODBC SQL is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if minimum ODBC SQL is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_minimum_sql_grammar(final CodeRunner ctxt,
                                                                                  final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsMinimumSQLGrammar() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_minimum_sql_grammar(CodeRunner, Value)'

    /**
     * Tests whether mixed case identifiers are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if mixed case identifiers are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_mixed_case_identifiers(final CodeRunner ctxt,
                                                                                     final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsMixedCaseIdentifiers() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_mixed_case_identifiers(CodeRunner, Value)'

    /**
     * Tests whether mixed case quoted identifiers are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if mixed case quoted identifiers are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_mixed_case_quoted_identifiers(final CodeRunner ctxt,
                                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsMixedCaseQuotedIdentifiers() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_mixed_case_quoted_identifiers(CodeRunner, Value)'

    /**
     * Tests whether multiple open result sets are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if multiple open result sets are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_multiple_open_results(final CodeRunner ctxt,
                                                                                    final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsMultipleOpenResults() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_multiple_open_results(CodeRunner, Value)'

    /**
     * Tests whether multiple result sets are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if multiple result sets are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_multiple_result_sets(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsMultipleResultSets() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_multiple_result_sets(CodeRunner, Value)'

    /**
     * Tests whether multiple transactions are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if multiple transactions are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_multiple_transactions(final CodeRunner ctxt,
                                                                                    final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsMultipleTransactions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_multiple_transactions(CodeRunner, Value)'

    /**
     * Tests whether named parameters are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if named parameters are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_named_parameters(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsNamedParameters() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_named_parameters(CodeRunner, Value)'

    /**
     * Tests whether non-nullable columns are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if non-nullable columns are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_non_nullable_columns(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsNonNullableColumns() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_non_nullable_columns(CodeRunner, Value)'

    /**
     * Tests whether open cursors are supported across commits.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if open cursors are supported across commits,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_open_cursors_across_commit(final CodeRunner ctxt,
                                                                                         final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsOpenCursorsAcrossCommit() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_open_cursors_across_commit(CodeRunner, Value)'

    /**
     * Tests whether open cursors are supported across rollbacks.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if open cursors are supported across rollbacks,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_open_cursors_across_rollback(final CodeRunner ctxt,
                                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsOpenCursorsAcrossRollback() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_open_cursors_across_rollback(CodeRunner, Value)'

    /**
     * Tests whether open statements are supported across commits.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if open statements are supported across commits,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_open_statements_across_commit(final CodeRunner ctxt,
                                                                                            final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsOpenStatementsAcrossCommit() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_open_statements_across_commit(CodeRunner, Value)'

    /**
     * Tests whether open statements are supported across rollbacks.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if open statements are supported across rollbacks,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_open_statements_across_rollback(final CodeRunner ctxt,
                                                                                              final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsOpenStatementsAcrossRollback() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_open_statements_across_rollback(CodeRunner, Value)'

    /**
     * Tests whether unrelated <i>order by</i> clauses are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if unrelated <i>order by</i> clauses are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_order_by_unrelated(final CodeRunner ctxt,
                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsOrderByUnrelated() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_order_by_unrelated(CodeRunner, Value)'

    /**
     * Tests whether outer joins are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if outer joins are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_outer_joins(final CodeRunner ctxt,
                                                                          final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsOuterJoins() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_outer_joins(CodeRunner, Value)'

    /**
     * Tests whether positioned deletes are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if positioned deletes are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_positioned_delete(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsPositionedDelete() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_positioned_delete(CodeRunner, Value)'

    /**
     * Tests whether positioned updates are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if positioned updates are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_positioned_update(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsPositionedUpdate() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_positioned_update(CodeRunner, Value)'

    /**
     * Tests whether a concurrency/type combination is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param type result set type
     * @param concurrency result set concurrency
     * @return <tt>true</tt> if a concurrency/type combination is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_result_set_concurrency(final CodeRunner ctxt,
                                                                                     final Value databasemetadata,
                                                                                     final Value type,
                                                                                     final Value concurrency)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsResultSetConcurrency(Misc.decodeResultSetType(type),
                                                    Misc.decodeResultSetConcurrency(concurrency))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_result_set_concurrency(CodeRunner, Value, Value, Value)'

    /**
     * Tests whether a holdability is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param holdability result set holdability
     * @return <tt>true</tt> if a holdability is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_result_set_holdability(final CodeRunner ctxt,
                                                                                     final Value databasemetadata,
                                                                                     final Value holdability)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsResultSetHoldability(Misc.decodeResultSetHoldability(holdability))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_result_set_holdability(CodeRunner, Value, Value)'

    /**
     * Tests whether a result set type is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param type result set type
     * @return <tt>true</tt> if a result set type is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_result_set_type(final CodeRunner ctxt,
                                                                              final Value databasemetadata,
                                                                              final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsResultSetType(Misc.decodeResultSetType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_result_set_type(CodeRunner, Value, Value)'

    /**
     * Tests whether savepoints are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if savepoints are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_savepoints(final CodeRunner ctxt,
                                                                         final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSavepoints() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_savepoints(CodeRunner, Value)'

    /**
     * Tests whether schemas are supported in data manipulation.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if schemas are supported in data manipulation,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_schemas_in_data_manipulation(final CodeRunner ctxt,
                                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSchemasInDataManipulation() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_schemas_in_data_manipulation(CodeRunner, Value)'

    /**
     * Tests whether schemas are supported in index definition.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if schemas are supported in index definition,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_schemas_in_index_definitions(final CodeRunner ctxt,
                                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSchemasInIndexDefinitions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_schemas_in_index_definitions(CodeRunner, Value)'

    /**
     * Tests whether schemas are supported in privilege definition.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if schemas are supported in privilege definition,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_schemas_in_privilege_definitions(final CodeRunner ctxt,
                                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSchemasInPrivilegeDefinitions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_schemas_in_privilege_definitions(CodeRunner, Value)'

    /**
     * Tests whether schemas are supported in procedure call.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if schemas are supported in procedure call,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_schemas_in_procedure_calls(final CodeRunner ctxt,
                                                                                         final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSchemasInProcedureCalls() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_schemas_in_procedure_calls(CodeRunner, Value)'

    /**
     * Tests whether schemas are supported in table definition.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if schemas are supported in table definition,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_schemas_in_table_definitions(final CodeRunner ctxt,
                                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSchemasInTableDefinitions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_schemas_in_table_definitions(CodeRunner, Value)'

    /**
     * Tests whether <i>select for update</i> is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if <i>select for update</i> is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_select_for_update(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSelectForUpdate() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_select_for_update(CodeRunner, Value)'

    /**
     * Tests whether statement pooling is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if statement pooling is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_statement_pooling(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsStatementPooling() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_statement_pooling(CodeRunner, Value)'

    /**
     * Tests whether stored functions can be invoked using call syntax.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if stored functions can be invoked using call syntax,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_stored_functions_using_call_syntax(final CodeRunner ctxt,
                                                                                                 final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsStoredFunctionsUsingCallSyntax() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_stored_functions_using_call_syntax(CodeRunner, Value)'

    /**
     * Tests whether stored functions are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if stored functions are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_stored_procedures(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsStoredProcedures() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_stored_procedures(CodeRunner, Value)'

    /**
     * Tests whether subqueries are supported in comparison expressions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if subqueries are supported in comparison expressions,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_subqueries_in_comparisons(final CodeRunner ctxt,
                                                                                        final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSubqueriesInComparisons() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_subqueries_in_comparisons(CodeRunner, Value)'

    /**
     * Tests whether subqueries are supported in <i>exists</i> expressions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if subqueries are supported in <i>exists</i> expressions,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_subqueries_in_exists(final CodeRunner ctxt,
                                                                                   final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSubqueriesInExists() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_subqueries_in_exists(CodeRunner, Value)'

    /**
     * Tests whether subqueries are supported in <i>in</i> expressions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if subqueries are supported in <i>in</i> expressions,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_subqueries_in_ins(final CodeRunner ctxt,
                                                                                final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSubqueriesInIns() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_subqueries_in_ins(CodeRunner, Value)'

    /**
     * Tests whether subqueries are supported in quantified expressions.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if subqueries are supported in quantified expressions,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_subqueries_in_quantifieds(final CodeRunner ctxt,
                                                                                        final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsSubqueriesInQuantifieds() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_subqueries_in_quantifieds(CodeRunner, Value)'

    /**
     * Tests whether table correlation names are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if table correlation names are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_table_correlation_names(final CodeRunner ctxt,
                                                                                      final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsTableCorrelationNames() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_table_correlation_names(CodeRunner, Value)'

    /**
     * Tests whether the passed transaction isolation level is supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @param level transaction isolation level
     * @return <tt>true</tt> if the passed transaction isolation level is supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_transaction_isolation_level(final CodeRunner ctxt,
                                                                                          final Value databasemetadata,
                                                                                          final Value level)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsTransactionIsolationLevel(Misc.decodeTransactionIsolation(level))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_transaction_isolation_level(CodeRunner, Value, Value)'

    /**
     * Tests whether transactions are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if transactions are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_transactions(final CodeRunner ctxt,
                                                                           final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsTransactions() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_transactions(CodeRunner, Value)'

    /**
     * Tests whether unions are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if unions are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_union(final CodeRunner ctxt,
                                                                    final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsUnion() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_union(CodeRunner, Value)'

    /**
     * Tests whether unions (<i>union all</i> expression) are supported.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if unions (<i>union all</i> expression) are supported,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_supports_union_all(final CodeRunner ctxt,
                                                                        final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.supportsUnionAll() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_supports_union_all(CodeRunner, Value)'

    /**
     * Tests whether updates are detected.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if updates are detected,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_updates_are_detected(final CodeRunner ctxt,
                                                                          final Value databasemetadata,
                                                                          final Value type)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.updatesAreDetected(Misc.decodeJDBCType(type))
                ? Value.TRUE
                : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_updates_are_detected(CodeRunner, Value, Value)'

    /**
     * Tests whether database storage uses a file per table.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if database storage uses a file per table,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_uses_local_file_per_table(final CodeRunner ctxt,
                                                                               final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.usesLocalFilePerTable() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_uses_local_file_per_table(CodeRunner, Value)'

    /**
     * Tests whether database storage uses files.
     * @param ctxt context
     * @param databasemetadata database metadata
     * @return <tt>true</tt> if database storage uses files,
     *         <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_databasemetadata_uses_local_files(final CodeRunner ctxt,
                                                                      final Value databasemetadata)
        throws Fail.Exception {
        try {
            final DatabaseMetaData dmd = (DatabaseMetaData) databasemetadata.asBlock().asCustom();
            return dmd.usesLocalFiles() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_databasemetadata_uses_local_files(CodeRunner, Value)'

} // end class 'DatabaseMetaDatas'
